
$(function(){

	
	window.Model = Backbone.Model.extend({  
	    // 模型值校验  
	    validate:function(attrs){  
	        for(var key in attrs){  
	            if(attrs[key] == ''){  
	                return key + "不能为空";  
	            }  
	            if(key == 'age' && isNaN(attrs.age)){  
	                return "年龄必须是数字";  
	            }  
	        }  
	    }  
	
	
	}); 
	   
	   SearchView = Backbone.View.extend({

		    initialize: function(){

		        this.render();

		    },

		    render: function() {
		    	var model = new Model();  
		        //使用underscore这个库，来编译模板
		    	
		    	model.set({'title':"测试",'link':'www.baidu.com'});  

		        var template = _.template($("#text_nav").html(),{title:"导航标题",link:"www.baidu.com"});   //获取页面模版    search_label 赋值

		        //加载模板到对应的el属性中

		        //this.el.html(template);
		        $(this.el).html(template);
		    },

		    events:{  

		       'click  span' : 'doSearch'  //定义类型为button的input标签的点击事件，触发函数doSearch

		    },

		    doSearch: function(event){

		        alert("search for ");

		    }


		});
	   
	   
	   
	   var searchView = new SearchView({el: $("#apps_lijigou")});

	   searchView.render();  //这个reander的方法可以放到view的构造函数中


});
